package com.tang.campus_market.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.tang.campus_market.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ Author     ：Marine.Li
 * @ Date       ：Created in 14:28 2021/8/5
 * @ Description：订单Mapper层
 * @ Modified By：
 * @Version: 1.0.0$
 */

@Mapper
public interface OrderDao extends BaseMapper<Order> {
    @Select("SELECT id,seller,good_id,good_name,money,submit_date,STATUS FROM market_order")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "seller", column = "seller"),
            @Result(property = "goodId", column = "good_id"),
            @Result(property = "goodName", column = "good_name"),
            @Result(property = "submitDate", column = "submit_date"),
            @Result(property = "status", column = "status"),
    })
    List<Order> findAll();
    
    @Select("SELECT id from market_order WHERE good_id = #{goodId}")
    Order findByGoodId(Integer goodId);
}
